﻿using TestBat.IViewModels.Dialogs;

namespace TestBat.ViewModels.Base
{
    public class DialogViewModelContainer : ViewModel, IDialogViewModelContainer
    {
        public IDialogViewModel DialogViewModel
        {
            get { return dialogViewModel; }
            set
            {
                dialogViewModel = value;
                if (dialogViewModel != null) // register the close event which detaches the ViewModel again
                    dialogViewModel.CloseEvent += delegate { DialogViewModel = null; };
                NotifyPropertyChanged(() => this.DialogViewModel);
            }
        }

        private IDialogViewModel dialogViewModel;
    }
}
